//
//  JSMStrategyContinentDetailTableViewCell.m
//  TakeYouTourTogether
//
//  Created by king on 15/12/6.
//  Copyright © 2015年 king. All rights reserved.
//

#import "JSMStrategyContinentDetailTableViewCell.h"
#import "JSMStrategyContinentDetailCollectionViewCell.h"
#import "JSMStrategyContinentDetailHotModel.h"

@implementation JSMStrategyContinentDetailTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createStrategyContinentDetailTableViewCell];
    }
    return self;
}

- (void)createStrategyContinentDetailTableViewCell {
    self.myImageView = [[BaseImageView alloc] init];
    self.myImageView.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.myImageView];
    
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
    flowLayout.itemSize = CGSizeMake(SCREEN_WIDTH/3/2, SCREEN_WIDTH/6);
    flowLayout.minimumInteritemSpacing = 0;
    flowLayout.minimumLineSpacing = 0;
    flowLayout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
    
    self.myCollection = [[BaseCollectionView alloc] initWithFrame:CGRectMake(0, 0, 0, 0) collectionViewLayout:flowLayout];
    self.myCollection.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.myCollection];
    self.myCollection.showsHorizontalScrollIndicator = NO;
    self.myCollection.showsVerticalScrollIndicator = NO;
    self.myCollection.delegate = self;
    self.myCollection.dataSource = self;
    [self.myCollection registerClass:[JSMStrategyContinentDetailCollectionViewCell class] forCellWithReuseIdentifier:@"asd"];
    
    self.myLabel = [[BaseLabel alloc] init];
    self.myLabel.backgroundColor = [UIColor clearColor];
    self.myLabel.textAlignment = NSTextAlignmentCenter;
    self.myLabel.font = [UIFont boldSystemFontOfSize:20];
    [self.contentView addSubview:self.myLabel];
    
    self.labelButton = [[BaseLabel alloc] init];
    self.labelButton.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.labelButton];
    self.labelButton.font = [UIFont systemFontOfSize:15];
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return self.dataAllArray.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    JSMStrategyContinentDetailCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"asd" forIndexPath:indexPath];
    
    JSMStrategyContinentDetailHotModel *temp = self.dataAllArray[indexPath.row];
    [cell.myImageView sd_setImageWithURL:[NSURL URLWithString:temp.photo] placeholderImage:[UIImage imageNamed:PLACE_HOLDER_IMAGE]];
//    cell.myImageView.image = [UIImage imageNamed:@"back1111.png"];
    return cell;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.myImageView.frame = CGRectMake(0, 0, SCREEN_WIDTH/3*2, SCREEN_WIDTH/2);
    self.myCollection.frame = CGRectMake(SCREEN_WIDTH/3*2, 0, SCREEN_WIDTH/3, SCREEN_WIDTH/2);
    self.myLabel.frame = CGRectMake(0, SCREEN_WIDTH/2, SCREEN_WIDTH-120, 40);
    self.labelButton.frame = CGRectMake(SCREEN_WIDTH-120, SCREEN_WIDTH/2, 120, 40);
}

- (void)setDataAllArray:(NSArray *)dataAllArray {
    if (_dataAllArray != dataAllArray) {
        _dataAllArray = dataAllArray;
    }
    [self.myCollection reloadData];
}

@end
